const config = require("../config/config");
const jwt = require("jsonwebtoken");
const chatserver = require("../NEDB/chatserver");
var usermodel = {
  getChathistory: function (req, res, next) {
    try {

      let prajson = { itemid: parseInt(req.query.itemid) }

      chatserver.List(prajson)
        .then((result) => {
          console.log(result);
          res.json(result);
        });
      // chatserver.Get({
      //   itemid: req.query.itemid,
      // })
      //   .then((result) => {
      //     console.log(result);
      //     res.json(result);
      //   });
    } catch (ex) {
      res.dealError(ex);
    }
  },
  newChat: function (req, res, next) {
    try {

      chatserver.Add(req.body).then((result) => {
        if (result.code !== 200) {
          return result;
        } else {
          res.json({
            code: 200,
          });
        }
      });
    } catch (ex) {
      res.dealError(ex);
    }
  },
};

module.exports = usermodel;
